package acwing.search;

import java.util.Scanner;

public class rangeOfNum_ {
    // 找第一个大于等于k和最后一个小于等于k的下标
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        while(q-- != 0){
            int target = sc.nextInt();
            int left = 0;
            int right = arr.length - 1;
            // 找第一个满足条件的值
            while(left <= right){
                int mid = left + right >> 1;
                if (arr[mid] >= target){
                    right = mid;
                }
                else{
                    left = mid + 1;
                }
            }
            if (arr[left] != target) System.out.println("-1 -1");
            else{
                System.out.print(left);
                left = 0;
                right = arr.length - 1;
                // 找到满足条件的最后一个值
                while(left <= right){
                    int mid = left + right + 1 >> 1;
                    if (arr[mid] <= target){
                        left = mid;
                    }
                    else{
                        right = mid - 1;
                    }
                }
                System.out.println(" " + left);
            }
        }
    }
}
